<html>
<head><meta charset="utf-8"><title>Maximum duration · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html">Maximum duration</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="198310099"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198310099" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198310099">(May 21 2020 at 11:23)</a>:</h4>
<p>Hello! Whats the best way to construct the biggest value a <code>Duration</code> can hold? Using <code>Duration::new(u64::MAX, u32::MAX)</code> will panic because of seconds overflow.</p>



<a name="198310170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198310170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198310170">(May 21 2020 at 11:24)</a>:</h4>
<p>I understand the panic, but it seems there is no easy way to build such <code>Duration::MAX</code> value</p>



<a name="198310220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198310220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198310220">(May 21 2020 at 11:25)</a>:</h4>
<p><a href="https://doc.rust-lang.org/src/core/time.rs.html#562-579">https://doc.rust-lang.org/src/core/time.rs.html#562-579</a> hmm</p>



<a name="198310592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198310592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198310592">(May 21 2020 at 11:31)</a>:</h4>
<p><code>Duration::new(u64::MAX, 1_000_000_000 - 1);</code></p>



<a name="198310597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198310597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198310597">(May 21 2020 at 11:32)</a>:</h4>
<p><code>Duration::new(u64::MAX, NANOS_PER_SEC-1)</code> seems to work but unfortunately i had to redefine <code>NANOS_PER_SEC</code> myself</p>



<a name="198310639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198310639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198310639">(May 21 2020 at 11:32)</a>:</h4>
<p>yeah right we came up with the same answer</p>



<a name="198310696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198310696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198310696">(May 21 2020 at 11:33)</a>:</h4>
<p>Would it be acceptable to have NANOS_PER_SEC (and probably the other related constants) as associated constants for Duration?</p>



<a name="198310780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198310780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198310780">(May 21 2020 at 11:34)</a>:</h4>
<p>or just exported in the time module</p>



<a name="198310952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198310952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198310952">(May 21 2020 at 11:37)</a>:</h4>
<p>Also <a href="https://github.com/rust-lang/rust/issues/32070">https://github.com/rust-lang/rust/issues/32070</a></p>



<a name="198311156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198311156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198311156">(May 21 2020 at 11:40)</a>:</h4>
<p>Apparently i am not the only trying to build such maximum duration</p>



<a name="198311885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198311885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198311885">(May 21 2020 at 11:50)</a>:</h4>
<p><code>Duration</code> is a bit of a mess :-(</p>



<a name="198311970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198311970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198311970">(May 21 2020 at 11:52)</a>:</h4>
<p>I'll do a PR that adds <code>Duration:::MAX</code> and we will see what happens :D</p>



<a name="198312083"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198312083" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198312083">(May 21 2020 at 11:54)</a>:</h4>
<p>Unfortunately, <code>Duration::new</code> is not <code>const</code></p>



<a name="198312334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198312334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198312334">(May 21 2020 at 11:57)</a>:</h4>
<p><span class="user-mention silent" data-user-id="203546">Laurențiu Nicola</span> <a href="#narrow/stream/122651-general/topic/Maximum.20duration/near/198312083">said</a>:</p>
<blockquote>
<p>Unfortunately, <code>Duration::new</code> is not <code>const</code></p>
</blockquote>
<p>hm, as a start someone could experiment with making the <code>checked_*</code> arithmetic methods <code>const fn</code></p>



<a name="198312358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198312358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198312358">(May 21 2020 at 11:57)</a>:</h4>
<p>that requires <code>const_if_match</code> but that's okay for unstable methods (and that feature will hopefully become stable Soon(TM) )</p>



<a name="198320897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198320897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198320897">(May 21 2020 at 13:34)</a>:</h4>
<p><span class="user-mention" data-user-id="120791">@RalfJ</span> i'd happy to help! What is required exactly to make <code>checked_*</code> function const? Only adding the feature gate + adding the const keyword?</p>



<a name="198321284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198321284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198321284">(May 21 2020 at 13:38)</a>:</h4>
<p>well... I don't know for sure, I am only following constification at a distance</p>



<a name="198321320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198321320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198321320">(May 21 2020 at 13:38)</a>:</h4>
<p>so I'd start by adding <code>const fn</code> and <code>#[rustc_const_unstable]</code></p>



<a name="198321326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198321326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198321326">(May 21 2020 at 13:38)</a>:</h4>
<p>and then let the compiler errors guide me</p>



<a name="198321506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198321506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198321506">(May 21 2020 at 13:40)</a>:</h4>
<p>I dont know what our current story is for "internal instability" but that only really matters once we try to stabilize them -- so, not for now.</p>



<a name="198321605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198321605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198321605">(May 21 2020 at 13:41)</a>:</h4>
<p><span class="user-mention" data-user-id="281572">@marmeladema</span> ^</p>



<a name="198321803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198321803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198321803">(May 21 2020 at 13:42)</a>:</h4>
<p>Ok, i'll try to do something! Worst case scenario, reviewer screams at me :D</p>



<a name="198321864"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198321864" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198321864">(May 21 2020 at 13:43)</a>:</h4>
<blockquote>
<p>Worst case scenario, reviewer screams at me</p>
</blockquote>
<p>Isn't that also the best case scenario? <span aria-label="big smile" class="emoji emoji-1f604" role="img" title="big smile">:big_smile:</span></p>



<a name="198322282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198322282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198322282">(May 21 2020 at 13:46)</a>:</h4>
<p>our reviewers should be more kind than that ;)</p>



<a name="198322303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198322303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198322303">(May 21 2020 at 13:46)</a>:</h4>
<p>oh and make sure to also add a testcase, otherwise the reviewer will definitely demand that :D</p>



<a name="198322364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198322364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198322364">(May 21 2020 at 13:47)</a>:</h4>
<p>we already have a bunch of const-int-arith test file in <code>src/test/ui/consts</code>, see if there's a good file to add these two or if it seems more sensible to add a new file</p>



<a name="198322883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198322883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198322883">(May 21 2020 at 13:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/122651-general/topic/Maximum.20duration/near/198322282">said</a>:</p>
<blockquote>
<p>our reviewers should be more kind than that ;)</p>
</blockquote>
<p>Just kidding :D</p>



<a name="198359157"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198359157" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198359157">(May 21 2020 at 18:38)</a>:</h4>
<p>So checked_add is already const apparently</p>



<a name="198359302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198359302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198359302">(May 21 2020 at 18:40)</a>:</h4>
<p><code>Duration::new</code> cannot be made const because of the call to <code>.expect(..)</code></p>



<a name="198360808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198360808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198360808">(May 21 2020 at 18:53)</a>:</h4>
<p>Matching and calling panic manually seems to do the trick BUT new method is already tagged with <code>#[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]</code> which means i cannot just add <code>#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")]</code></p>



<a name="198363267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198363267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198363267">(May 21 2020 at 19:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281572">marmeladema</span> <a href="#narrow/stream/122651-general/topic/Maximum.20duration/near/198359157">said</a>:</p>
<blockquote>
<p>So checked_add is already const apparently</p>
</blockquote>
<p>doesn't look like it: <a href="https://doc.rust-lang.org/nightly/std/primitive.i64.html#method.checked_add">https://doc.rust-lang.org/nightly/std/primitive.i64.html#method.checked_add</a></p>



<a name="198363343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198363343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198363343">(May 21 2020 at 19:12)</a>:</h4>
<p>at last I think that would say <code>const</code> explicitly?</p>



<a name="198363365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198363365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198363365">(May 21 2020 at 19:12)</a>:</h4>
<p>yes it would</p>



<a name="198363387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198363387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198363387">(May 21 2020 at 19:13)</a>:</h4>
<blockquote>
<p>new method is already tagged with #[rustc_const_stable(feature = "duration_consts", since = "1.32.0")]</p>
</blockquote>
<p>only <code>const</code> methods should be tagged with that...? which new method do you mean?</p>



<a name="198363456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198363456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198363456">(May 21 2020 at 19:13)</a>:</h4>
<p><code>Duration::new</code></p>



<a name="198363534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198363534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198363534">(May 21 2020 at 19:14)</a>:</h4>
<p><a href="https://doc.rust-lang.org/src/core/time.rs.html#134">https://doc.rust-lang.org/src/core/time.rs.html#134</a></p>



<a name="198363636"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198363636" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198363636">(May 21 2020 at 19:15)</a>:</h4>
<p>Afaik these attributes don't actually do anything if the given function is not const</p>



<a name="198363650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198363650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198363650">(May 21 2020 at 19:15)</a>:</h4>
<p>There was some issue on github for that</p>



<a name="198363702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198363702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198363702">(May 21 2020 at 19:15)</a>:</h4>
<p>that makes no sense... <span class="user-mention" data-user-id="124288">@oli</span> any idea why it should have that attribute?</p>



<a name="198363859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198363859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198363859">(May 21 2020 at 19:17)</a>:</h4>
<p>It's <a href="https://github.com/rust-lang/rust/issues/69630">https://github.com/rust-lang/rust/issues/69630</a></p>



<a name="198364062"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198364062" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198364062">(May 21 2020 at 19:18)</a>:</h4>
<p>well for now let's clean this one up: <a href="https://github.com/rust-lang/rust/pull/72434">https://github.com/rust-lang/rust/pull/72434</a></p>



<a name="198364127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198364127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198364127">(May 21 2020 at 19:19)</a>:</h4>
<p><span class="user-mention" data-user-id="281572">@marmeladema</span> I'll close that PR if you have one that makes it actually const. (unstably).. feel free to just remove the existing attribute if it gets in your way.</p>



<a name="198364162"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198364162" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198364162">(May 21 2020 at 19:19)</a>:</h4>
<p>and yes you'll have to make <code>Option::except</code> unstably const as well</p>



<a name="198364296"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198364296" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198364296">(May 21 2020 at 19:21)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/master/src/libcore/num/mod.rs#L746">https://github.com/rust-lang/rust/blob/master/src/libcore/num/mod.rs#L746</a><br>
this is the checked_add implem that I looked at</p>



<a name="198364452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198364452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198364452">(May 21 2020 at 19:22)</a>:</h4>
<p>hm... maybe rustdoc does not render the <code>const</code> when it is unstable</p>



<a name="198364460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198364460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198364460">(May 21 2020 at 19:22)</a>:</h4>
<p>well that means less work for you then, nice :D</p>



<a name="198364596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198364596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198364596">(May 21 2020 at 19:23)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/compare/master...marmeladema:duration-new-const?expand=1">https://github.com/rust-lang/rust/compare/master...marmeladema:duration-new-const?expand=1</a><br>
this is what i tried and the compiler does not seem to complain</p>



<a name="198365934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198365934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198365934">(May 21 2020 at 19:34)</a>:</h4>
<p>sure that also works</p>



<a name="198365964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198365964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198365964">(May 21 2020 at 19:35)</a>:</h4>
<p>though the constant <code>MAX</code> you added seems orthogonal, and should be a separate feature IMO</p>



<a name="198366011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198366011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198366011">(May 21 2020 at 19:35)</a>:</h4>
<p>oh you made them separate :)</p>



<a name="198366055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198366055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198366055">(May 21 2020 at 19:35)</a>:</h4>
<p>hm re-using "const_checked_int_methods" for <code>Duration::new</code> is a bit fishy though</p>



<a name="198366637"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198366637" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198366637">(May 21 2020 at 19:40)</a>:</h4>
<p>I open-ed <a href="https://github.com/rust-lang/rust/pull/72436">https://github.com/rust-lang/rust/pull/72436</a> for the sake of it</p>



<a name="198366683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198366683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198366683">(May 21 2020 at 19:41)</a>:</h4>
<p>i've never modified any user visible code from standard library so it might be totally none sense^^</p>



<a name="198367854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198367854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198367854">(May 21 2020 at 19:52)</a>:</h4>
<p>I'd also like to add <code>Duration::saturating_add</code> and <code>Duration::saturating_sub</code></p>



<a name="198368822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198368822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198368822">(May 21 2020 at 19:59)</a>:</h4>
<p><span class="user-mention" data-user-id="281572">@marmeladema</span> as mentioned above, usually new <code>const fn</code> come with a UI test ensuring their correct functionality</p>



<a name="198369067"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198369067" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198369067">(May 21 2020 at 20:00)</a>:</h4>
<p>Oh yeah right sorry, i'll add one later tonight</p>



<a name="198373253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198373253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198373253">(May 21 2020 at 20:32)</a>:</h4>
<p>"tonight" <span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span></p>



<a name="198382385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198382385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198382385">(May 21 2020 at 21:57)</a>:</h4>
<p>So i ran a bit more experiments, and most of non-trait <code>Duration</code> methods can be made const</p>



<a name="198383047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198383047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198383047">(May 21 2020 at 22:04)</a>:</h4>
<p>I just have a question about feature and unstability. Why would it be wrong it use an already existing feature like <code>#[rustc_const_stable(feature = "duration_consts", since = "1.45.0")]</code> (using the version its going to be released of course) to get instantaneous stable const methods?</p>



<a name="198385703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198385703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198385703">(May 21 2020 at 22:31)</a>:</h4>
<p>Its a bit stressful to create a 'tracking issue', it feels like a lot of responsibility now but here we go: <a href="https://github.com/rust-lang/rust/issues/72440">https://github.com/rust-lang/rust/issues/72440</a><br>
I hope i did not make such a bad job at it</p>



<a name="198388206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198388206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198388206">(May 21 2020 at 22:55)</a>:</h4>
<p>that looks pretty good!</p>



<a name="198488330"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198488330" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198488330">(May 22 2020 at 20:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281572">marmeladema</span> <a href="#narrow/stream/122651-general/topic/Maximum.20duration/near/198385703">said</a>:</p>
<blockquote>
<p>Its a bit stressful to create a 'tracking issue', it feels like a lot of responsibility now but here we go: <a href="https://github.com/rust-lang/rust/issues/72440">https://github.com/rust-lang/rust/issues/72440</a><br>
I hope i did not make such a bad job at it</p>
</blockquote>
<p>yeah I know it can feel intimidating. alternatively you can always ask a team member to do it for you. :)</p>



<a name="198488389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198488389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198488389">(May 22 2020 at 20:00)</a>:</h4>
<p>but to tell you the truth, I am also somewhat intimidated by it. :D you did a great job!</p>



<a name="198498217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Maximum%20duration/near/198498217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> marmeladema <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Maximum.20duration.html#198498217">(May 22 2020 at 21:43)</a>:</h4>
<p>Thanks :) i am writing tests right now and will open a PR soon</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>